package com.edu.cdp.utils;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Random;

public class NumberUtils {
    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
    private static final Random random = new Random();
    /**
     * 生成员工编号
     * @return 员工编号
     */
    public String getJobNumber() {
        SimpleDateFormat sdf = new SimpleDateFormat("yMdhms");
        return sdf.format(new Date());
    }

    /**
     *  生成订单编号
     * @return 订单编号
     */
    public String getOrderNumber() {
       String timeNumber = formatter.format(LocalDateTime.now());
       int randomNumber = random.nextInt(1000) + 9999;

        return timeNumber + randomNumber;
    }

    public static void main(String[] args) {
        NumberUtils numberUtils = new NumberUtils();
        System.out.println(numberUtils.getJobNumber());
        System.out.println(numberUtils.getOrderNumber());
    }
}